using System;

namespace DL
{

    public readonly struct GameBlackboardKey : IEquatable<GameBlackboardKey>
    {
        private readonly string m_Name;
        private readonly int m_HashCode;

        public GameBlackboardKey(string name)
        {
            m_Name = name;
            m_HashCode = name.ComputeFNV1aHash();
        }

        public bool Equals(GameBlackboardKey other) => this.m_HashCode == other.m_HashCode;
        
        public override string ToString() => m_Name;
        public override int GetHashCode() => m_HashCode;

        public static bool operator !=(GameBlackboardKey lhs, GameBlackboardKey rhs)
        {
            return !(lhs == rhs);
        }
        public static bool operator ==(GameBlackboardKey lhs, GameBlackboardKey rhs)
        {
            return lhs.m_HashCode == rhs.m_HashCode;
        }
        public override bool Equals(object obj)
        {
            return obj is GameBlackboardKey other && Equals(other);
        }

    }
}